#2020年省赛-填空题 回文日期
import datetime

date = input()  #分割日期
y = int(date[0:4])
m = int(date[4:6])
d = int(date[6:8])

dd = datetime.date(y, m, d)
flag = True
while True:
    dd = dd +datetime.timedelta(days=1)  # 日期加1
    strdd = str(dd).replace('-', '')  # 字符串化并移除'-'为''
    if strdd == strdd[::-1]:
        if flag:
            print(strdd)
            flag = False
        if strdd[0] == strdd[2] == strdd[5] == strdd[7] and strdd[1] == strdd[3] == strdd[4] == strdd[6]:
            print(strdd)
            break
